package inet.app.vod.object;

import inet.app.vod.config.AppConstants;

import java.util.ArrayList;

import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;

public class MovieModel extends SlideObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@SerializedName("ENG_NAME")
	private String titleEng;

	@SerializedName("TYPE")
	private String type;

	@SerializedName("DESCR")
	private String descriptions;

	@SerializedName("IMDB")
	private String imdb;

	@SerializedName("TIME")
	private String time;

	@SerializedName("VIEW")
	private int numView;

	private int episodeNum;

	// danh sách tập video
	private ArrayList<MovieModel> listPart = new ArrayList<MovieModel>();

	public MovieModel() {
		titleEng = "";
		type = "";
		descriptions = "";
		imdb = "";
		time = "";
		episodeNum = 1;
		numView = 0;
	}

	public MovieModel(String id, String img, String title) {
		super(id, img, title);
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDescriptions() {
		return descriptions;
	}

	public void setDescriptions(String descriptions) {
		this.descriptions = descriptions;
	}

	public String getImdb() {
		return imdb;
	}

	public void setImdb(String imdb) {
		this.imdb = imdb;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public int getEpisodeNum() {
		return episodeNum;
	}

	public void setEpisodeNum(int episodeNum) {
		this.episodeNum = episodeNum;
	}

	public ArrayList<MovieModel> getListPart() {
		return listPart;
	}

	public void setListPart(ArrayList<MovieModel> listPart) {
		this.listPart = listPart;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getTitleEng() {
		return titleEng;
	}

	public void setTitleEng(String titleEng) {
		this.titleEng = titleEng;
	}

	public int getNumView() {
		return numView;
	}

	public void setNumView(int numView) {
		this.numView = numView;
	}

	public String getLinkMovie(int ep) {
		boolean isClip = false;
		if (TextUtils.isEmpty(type) && TextUtils.isEmpty(imdb)) {
			isClip = true;
		}
		String relativeLink = isClip ? "/middleware/videos/Clips/"
				: "/middleware/videos/HDs/";
		String name = "";
		if (isClip) {
			name = titleEng.toLowerCase();
		} else {
			name = new StringBuffer(titleEng.toLowerCase()).append("-")
					.append(ep).toString();
		}
		String linkMovie = new StringBuffer("http://")
				.append(AppConstants.SERVER_HOST).append(":")
				.append(AppConstants.SERVER_PORT).append(relativeLink)
				.append(name).append(".mp4").toString();
		return linkMovie;
	}

	public String getSubtitleLink(int ep) {
		String linkSubtitle;
		boolean isClip = false;
		if (TextUtils.isEmpty(type) && TextUtils.isEmpty(imdb)) {
			isClip = true;
		}
		if (isClip) {
			linkSubtitle = "";
		} else {
			linkSubtitle = new StringBuffer("http://iphim.vn/shared/subtitles/")
					.append(titleEng.toLowerCase()).append("-").append(ep)
					.append(".srt").toString();
		}
		return linkSubtitle;
	}

	@Override
	public String toString() {
		return "MovieModel [titleEng=" + titleEng + ", type=" + type
				+ ", descriptions=" + descriptions + ", imdb=" + imdb
				+ ", time=" + time + ", numView=" + numView + ", episodeNum="
				+ episodeNum + ", listPart=" + listPart + ", id=" + id
				+ ", img=" + img + ", title=" + title + ", fbLink=" + fbLink
				+ "]";
	}

}
